<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <title>首页</title>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <link rel="stylesheet" href="/AdminLTE-2.3.11/bootstrap/css/bootstrap.min.css"/>
  <link rel="stylesheet" href="/bootstrap-table/src/bootstrap-table.css"/>
  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css"/>
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css"/>
  <!-- Theme style -->
  <link rel="stylesheet" href="/AdminLTE-2.3.11/dist/css/AdminLTE.min.css"/>
  <!-- AdminLTE Skins. We have chosen the skin-blue for this starter
        page. However, you can choose any other skin. Make sure you
        apply the skin class to the body tag so the changes take effect.
  -->
  <link rel="stylesheet" href="/AdminLTE-2.3.11/dist/css/skins/skin-blue.min.css"/>

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>
<body class="hold-transition skin-blue">
<div class="wrapper">

  <!-- Main Header -->
  <header class="main-header">

    <!-- Logo -->
    <a href="#" class="logo">
      <span class="logo-lg"><b>东溪</b>励氏族谱</span>
    </a>

    <!-- Header Navbar -->
    <nav class="navbar navbar-static-top" role="navigation">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
        <span class="sr-only">Toggle navigation</span>
      </a>
    </nav>
  </header>
  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar">

    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">

      <!-- Sidebar user panel (optional) -->
      <div class="user-panel">
        <div class="pull-left image">
          <img src="/AdminLTE-2.3.11/dist/img/user2-160x160.jpg" class="img-circle" alt="User Image"/>
        </div>
        <div class="pull-left info">
          <p>后台管理员</p>
          <!-- Status -->
          <a href="#"><i class="fa fa-circle text-success"></i> Online</a>
        </div>
      </div>

      <ul class="sidebar-menu">
        <li class="header">菜单</li>
        <!-- Optionally, you can add icons to the links -->
        <li class="treeview active">
          <a href="#"><i class="fa fa-link"></i> <span>族谱搜索</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="/sys/index">族谱树</a></li>
            <li><a href="/sys/zpSearch">成员搜索</a></li>
          </ul>
        </li>
        <li class="treeview">
          <a href="#"><i class="fa fa-link"></i> <span>族谱成员管理</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="/sys/addData">成员录入</a></li>
            <li><a href="/sys/update">成员更新</a></li>
            <li><a href="/sys/delete">成员删除</a></li>
          </ul>
        </li>
        <li class="treeview">
          <a href="#"><i class="fa fa-link"></i> <span>族谱信息统计</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="/sys/stat">按世代统计人口数</a></li>
          </ul>
        </li>
        <li><a href="/"><i class="fa fa-link"></i> <span>图说东溪</span></a></li>
      </ul>
      <!-- /.sidebar-menu -->
    </section>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        成员搜索
      </h1>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="box box-primary">
          <div class="box box-primary">
            <div class="box-header with-border">
              <div class="box-title">励氏族谱成员信息</div>
            </div>
            <div class="box-body">
              <div class="row">
                <div class="col-md-2">
                  <button class="btn btn-block btn-primary" onclick="searchParent()"><span class="glyphicon glyphicon-search"></span>查看父亲信息</button>
                </div>
                <div class="col-md-2">
                <button class="btn btn-block btn-primary" onclick="searchChild()"><span class="glyphicon glyphicon-search"></span>查看子女</button>
                </div>
                <div class="col-md-2">
                 <button class="btn btn-block btn-primary" onclick="searchXD()"><span class="glyphicon glyphicon-search"></span>查看亲兄弟姊妹</button>
                </div>
                <div class="col-md-2">
                  <button class="btn btn-block btn-primary" onclick="searchTXD()"><span class="glyphicon glyphicon-search"></span>查看堂兄弟姊妹</button>
                </div>
                <div class="col-md-2">
                  <button class="btn btn-block btn-primary" onclick="searchZPL()"><span class="glyphicon glyphicon-search"></span>查看个人族谱链</button>
                </div>
                <div class="col-md-2">
                  <button class="btn btn-block btn-primary" onclick="hdtt();"><span class="glyphicon glyphicon-search"></span>后代统计</button>
                </div>
              </div>
              <br/>
              <div class="row">
                <div class="col-md-2">
                  <label class="form-control text-center" >姓名：</label>
                </div>
                <div class="col-md-2">
                  <input id="pName" class="form-control" type="text"/>
                </div>
                <div class="col-md-2">
                  <button class="btn btn-block btn-primary" onclick="searchPersonFromName();"><span class="glyphicon glyphicon-search"></span>谱名查询</button>
                </div>
                <div class="col-md-2">
                  <button class="btn btn-block btn-primary" onclick="searchPersonFromIDName();"><span class="glyphicon glyphicon-search"></span>身份证姓名查询</button>
                </div>
                <div class="col-md-2">
                  <button class="btn btn-block btn-primary" onclick="searchPersonFromRName();"><span class="glyphicon glyphicon-search"></span>乳名查询</button>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="box box-primary">
          <table id="table"
                 data-toggle="table"
                 data-url="/search/getPage"
                 data-height="350"
                 data-detail-view="true"
                 data-side-pagination="server"
                 data-pagination="true"
                 data-detail-formatter="detailFormatter"
                 data-page-list="[5, 10, 20, 50, 100, 200]">
            <thead>
            <tr>
              <th data-field="state" data-radio="true"></th>
              <th data-field="id" data-visible="false">ID</th>
              <th data-field="name">谱名</th>
              <th data-field="rname">乳名</th>
              <th data-field="idname">身份证姓名</th>
              <th data-field="pid" data-visible="false">父节点id</th>
              <th data-field="rank">家中第几子</th>
              <th data-field="gene">代数</th>
              <th data-field="csrq">出生日期</th>
              <th data-field="swrq">死亡日期</th>
              <th data-field="wife">妻子</th>
              <th data-field="wcsrq">妻子出生日期</th>
              <th data-field="wswrq">妻子死亡日期</th>
              <th data-field="wintr" data-formatter="wifeFormatter">妻子介绍</th>
              <th data-field="addr" data-formatter="familyFormatter">家庭地址</th>
              <th data-field="intr" data-formatter="intrFormatter">个人简介（族谱介绍）</th>
              <th data-field="zi" data-width="100">字</th>
              <th data-field="gi">是否过继</th>
              <th data-field="dwife">是否多妻</th>
              <th data-field="edu">教育介绍</th>
              <th data-field="school">学校</th>
              <th data-field="hao" data-width="100">号</th>
            </tr>
            </thead>
          </table>
        </div>
      <div class="box box-primary">
        <div class="box-header with-border">
          <div class="box-title">查询结果</div>
        </div>
        <div class="box-body">
        <table id="table2"
               data-toggle="table"
               data-height="200">
          <thead>
          <tr>
            <th data-field="state" data-radio="true"></th>
            <th data-field="id" data-visible="false">ID</th>
            <th data-field="name">姓名</th>
            <th data-field="rname">乳名</th>
            <th data-field="idname">身份证姓名</th>
            <th data-field="pid" data-visible="false">父节点id</th>
            <th data-field="rank">家中第几子</th>
            <th data-field="gene">代数</th>
            <th data-field="csrq">出生日期</th>
            <th data-field="swrq">死亡日期</th>
            <th data-field="wife">妻子</th>
            <th data-field="wcsrq">妻子出生日期</th>
            <th data-field="wswrq">妻子死亡日期</th>
            <th data-field="wintr">妻子介绍</th>
            <th data-field="addr">家庭地址</th>
            <th data-field="intr">个人简介（族谱介绍）</th>
            <th data-field="zi" data-width="100">字</th>
            <th data-field="gi">是否过继</th>
            <th data-field="dwife">是否多妻</th>
            <th data-field="edu">教育介绍</th>
            <th data-field="school">学校</th>
            <th data-field="hao" data-width="100">号</th>
          </tr>
          </thead>
        </table>
        </div>
      </div>

    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <!-- Main Footer -->
  <footer class="main-footer">
    <!-- To the right -->
    <div class="pull-right hidden-xs">
      东溪励式族谱
    </div>
    <!-- Default to the left -->
    <strong>Copyright &copy; <a href="/">图说东溪</a>.</strong>
  </footer>

  <!-- Control Sidebar -->
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->

<!-- jQuery 2.2.3 -->
<script src="/AdminLTE-2.3.11/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="/AdminLTE-2.3.11/bootstrap/js/bootstrap.min.js"></script>
<script src="/bootstrap-table/src/bootstrap-table.js"></script>
<script src="/bootstrap-table/src/locale/bootstrap-table-zh-CN.js"></script>
<!-- AdminLTE App -->
<script src="/AdminLTE-2.3.11/dist/js/app.min.js"></script>
<script>
    //<![CDATA[
    var $table = $('#table');
    function wifeFormatter(value, row) {
        if(!value)
        {
            return ""
        }else if(value.length>3)
        {
            return value.substring(0,8)+"......";
        }else
        {
            return value;
        }
    }

    function familyFormatter(value, row) {
        if(!value)
        {
            return ""
        }else if(value.length>3)
        {
            return value.substring(0,8)+"......";
        }else
        {
            return value;
        }
    }
    function intrFormatter(value, row) {
        if(!value)
        {
            return ""
        }else if(value.length>3)
        {
            return value.substring(0,8)+"......";
        }else
        {
            return value;
        }
    }
    function detailFormatter(index, row) {
        var html = [];
        console.log(row)
        $.each(row, function (key, value) {
            if(key=="wintr" &&value){
                html.push('<p><b>' + "妻子介绍" + ':</b> ' + value + '</p>');
            }
            if(key=="addr"&&value){
                html.push('<p><b>' + "家庭介绍" + ':</b> ' + value + '</p>');
            }
            if(key=="intr"&&value){
                html.push('<p><b>' + "个人简介（族谱介绍）" + ':</b> ' + value + '</p>');
            }
        });
        return html.join('');
    }
    //]]>
</script>
<!-- Optionally, you can add Slimscroll and FastClick plugins.
     Both of these plugins are recommended to enhance the
     user experience. Slimscroll is required when using the
     fixed layout. -->
<script>
    function searchParent()
    {
        var rows=$table.bootstrapTable('getSelections')
        if(rows.length!=1)
        {
          alert("请选择成员！")
          return;
        }else
        {
          var pid=rows[0]["pid"]
            $.post("/search/parent",{
                pid:pid
            },function (data) {
                if(data=="")
                {
                    alert("没有查询到结果")
                }
                else
                {
                    alert("查询成功")
                    $("#table2").bootstrapTable('load',[data])
                }
            })
        }
    }
    function searchChild()
    {
        var rows=$table.bootstrapTable('getSelections')
        if(rows.length!=1)
        {
            alert("请选择成员！")
            return;
        }else
        {
            var pid=rows[0]["id"]
            $.post("/search/child",{
                pid:pid
            },function (data) {
                if(data=="")
                {
                    alert("没有查询到结果")
                }
                else
                {
                    console.log(data)
                    alert("查询成功")
                    $("#table2").bootstrapTable('load',data)
                }
            })
        }

    }
    function searchTXD() {
        var rows=$table.bootstrapTable('getSelections')
        if(rows.length!=1)
        {
            alert("请选择成员！")
            return;
        }else
        {
            var pid=rows[0]["pid"]
            $.post("/search/txd",{
                pid:pid
            },function (data) {
                if(data=="")
                {
                    alert("没有查询到结果")
                }
                else
                {
                    console.log(data)
                    alert("查询成功")
                    $("#table2").bootstrapTable('load',data)
                }
            })
        }
    }
    function searchXD()
    {
        var rows=$table.bootstrapTable('getSelections')
        if(rows.length!=1)
        {
            alert("请选择成员！")
            return;
        }else
        {
            var pid=rows[0]["pid"]
            $.post("/search/xd",{
                pid:pid,
                id:pid=rows[0]["id"]
            },function (data) {
                if(data=="")
                {
                    alert("没有查询到结果")
                }
                else
                {
                    console.log(data)
                    alert("查询成功")
                    $("#table2").bootstrapTable('load',data)
                }
            })
        }
    }
    function searchPersonFromName() {
        var rows = $table.bootstrapTable('getSelections')
        var name = $("#pName").val();
        if (name == "") {
            alert("请输入查询的名称！")
            return;
        } else {
            $.post("/search/personFromName", {
                name: name,
            }, function (data) {
                if (data.total == 0) {
                    alert("没有查询到结果")
                }
                else {
                    console.log(data)
                    alert("查询成功")
                    $("#table").bootstrapTable('load', data)


                }
            })
        }
    }
    function searchPersonFromRName() {
        var rows = $table.bootstrapTable('getSelections')
        var name = $("#pName").val();
        if (name == "") {
            alert("请输入查询的名称！")
            return;
        } else {
            $.post("/search/personFromRName", {
                rname: name,
            }, function (data) {
                if (data.total == 0) {
                    alert("没有查询到结果")
                }
                else {
                    console.log(data)
                    alert("查询成功")
                    $("#table").bootstrapTable('load', data)


                }
            })
        }
    }
    function searchPersonFromIDName() {
        var rows = $table.bootstrapTable('getSelections')
        var name = $("#pName").val();
        if (name == "") {
            alert("请输入查询的名称！")
            return;
        } else {
            $.post("/search/personFromIDName", {
                idname: name,
            }, function (data) {
                if (data.total == 0) {
                    alert("没有查询到结果")
                }
                else {
                    console.log(data)
                    alert("查询成功")
                    $("#table").bootstrapTable('load', data)


                }
            })
        }
    }
    function searchZPL() {
        var rows = $table.bootstrapTable('getSelections')
        if(rows.length!=1)
        {
            alert("请选择成员！")
            return;
        }else
        {
            var pid=rows[0]["pid"]
            $.post("/search/zpl",{
                pid:pid
            },function (data) {
                if(data=="")
                {
                    alert("没有查询到结果")
                }
                else
                {
                    console.log(data)
                    alert("查询成功")
                    $("#table2").bootstrapTable('load',data)
                }
            })
        }
    }
    function hdtt() {
        var rows=$table.bootstrapTable('getSelections')
        if(rows.length!=1)
        {
            alert("请选择成员！")
            return;
        }else
        {
            var id=rows[0]["id"]
            $.post("/search/hdtt",{
                id:id
            },function (data) {
                if(data=="")
                {
                    alert("没有查询到结果")
                }
                else
                {
                    alert("一共有："+data+"个后代")
                }
            })
        }
    }
</script>
</body>
</html>
